package com.ljfiction.book.adapter;

import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ljfiction.book.Baner.ShupingHuifuBean;
import com.ljfiction.book.R;
import com.ljfiction.book.tools.ScreenUtils;
import com.ljfiction.book.tools.TimeTool;

import java.util.List;

/**
 * Created by Android on 2017/11/2.
 */

public class ShupingHuifuAdapter extends BaseQuickAdapter<ShupingHuifuBean.DataBean.ListBean,BaseViewHolder>{
    public ShupingHuifuAdapter(@LayoutRes int layoutResId, @Nullable List<ShupingHuifuBean.DataBean.ListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ShupingHuifuBean.DataBean.ListBean item) {
        helper.setText(R.id.content_shupinghuifu,item.getReplyCommentsContent())
                .setText(R.id.name_shupinghuifu,item.getPseudonym())
                .setText(R.id.time_shupinghuifu, TimeTool.getTimeAndChange(String.valueOf(item.getCommentDateTime())))
                .setText(R.id.dengji_shupinghuifu,"LV"+item.getUserGrade());
        Glide.with(mContext).load(item.getUserHeadPortraitURL()).override(ScreenUtils.getNum(mContext,40),ScreenUtils.getNum(mContext,40)).into((ImageView) helper.getView(R.id.image_shupinghuifu));
        if (item.getUserSex()==0){
            ((ImageView) helper.getView(R.id.sex_shupinghuifu)).setImageResource(R.mipmap.sex_n);
        }else {
            ((ImageView) helper.getView(R.id.sex_shupinghuifu)).setImageResource(R.mipmap.sex_v);
        }
        if (item.getVipGrade()>0){
            helper.getView(R.id.isvip_shupinghuifu).setVisibility(View.VISIBLE);
        }else {
            helper.getView(R.id.isvip_shupinghuifu).setVisibility(View.GONE);
        }
        helper.addOnClickListener(R.id.image_shupinghuifu);
    }
}
